/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.BpmnPackage;
import bpmn.DataBased;
import bpmn.Gate;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Data Based</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.DataBasedImpl#getMarkerVisible <em>Marker Visible</em>}</li>
 *   <li>{@link bpmn.impl.DataBasedImpl#getDefaultGate <em>Default Gate</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DataBasedImpl extends ExclusiveImpl implements DataBased {
	/**
	 * The default value of the '{@link #getMarkerVisible() <em>Marker Visible</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMarkerVisible()
	 * @generated
	 * @ordered
	 */
	protected static final Boolean MARKER_VISIBLE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getMarkerVisible() <em>Marker Visible</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMarkerVisible()
	 * @generated
	 * @ordered
	 */
	protected Boolean markerVisible = MARKER_VISIBLE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getDefaultGate() <em>Default Gate</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDefaultGate()
	 * @generated
	 * @ordered
	 */
	protected Gate defaultGate;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DataBasedImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.DATA_BASED;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Boolean getMarkerVisible() {
		return markerVisible;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMarkerVisible(Boolean newMarkerVisible) {
		Boolean oldMarkerVisible = markerVisible;
		markerVisible = newMarkerVisible;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.DATA_BASED__MARKER_VISIBLE, oldMarkerVisible, markerVisible));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Gate getDefaultGate() {
		if (defaultGate != null && defaultGate.eIsProxy()) {
			InternalEObject oldDefaultGate = (InternalEObject)defaultGate;
			defaultGate = (Gate)eResolveProxy(oldDefaultGate);
			if (defaultGate != oldDefaultGate) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.DATA_BASED__DEFAULT_GATE, oldDefaultGate, defaultGate));
			}
		}
		return defaultGate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Gate basicGetDefaultGate() {
		return defaultGate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDefaultGate(Gate newDefaultGate) {
		Gate oldDefaultGate = defaultGate;
		defaultGate = newDefaultGate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.DATA_BASED__DEFAULT_GATE, oldDefaultGate, defaultGate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.DATA_BASED__MARKER_VISIBLE:
				return getMarkerVisible();
			case BpmnPackage.DATA_BASED__DEFAULT_GATE:
				if (resolve) return getDefaultGate();
				return basicGetDefaultGate();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.DATA_BASED__MARKER_VISIBLE:
				setMarkerVisible((Boolean)newValue);
				return;
			case BpmnPackage.DATA_BASED__DEFAULT_GATE:
				setDefaultGate((Gate)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.DATA_BASED__MARKER_VISIBLE:
				setMarkerVisible(MARKER_VISIBLE_EDEFAULT);
				return;
			case BpmnPackage.DATA_BASED__DEFAULT_GATE:
				setDefaultGate((Gate)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.DATA_BASED__MARKER_VISIBLE:
				return MARKER_VISIBLE_EDEFAULT == null ? markerVisible != null : !MARKER_VISIBLE_EDEFAULT.equals(markerVisible);
			case BpmnPackage.DATA_BASED__DEFAULT_GATE:
				return defaultGate != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (MarkerVisible: ");
		result.append(markerVisible);
		result.append(')');
		return result.toString();
	}

} //DataBasedImpl
